<?php
function represent_type_list($type_list, $old_type_id, $parent_type)
{
	$type_list_html = "";
	$type_list_html = "<select name=\"type\">\n";

	foreach ($type_list as $type)
	{
		if ($type["id"] == $old_type_id)
		{
			$type_list_html = $type_list_html . sprintf("<option value=\"%d\" selected=\"selected\">%s</option>\n", $type["id"], $type["name"]);
		}
		else
		{
			$type_list_html = $type_list_html . sprintf("<option value=\"%d\">%s</option>\n", $type["id"], $type["name"]);
		}
	}
	if ($old_type_id == NULL or $old_type_id == 0)
	{
		$type_list_html = $type_list_html . sprintf("<option value=\"0\" selected=\"selected\">未分类</option>\n");
	}
	else
	{
		$type_list_html = $type_list_html . sprintf("<option value=\"0\">未分类</option>\n");
	}
	$type_list_html = $type_list_html . "</select>\n";
	$type_list_html = $type_list_html . "<a href=\"../type/add.php?parent_type=" . $parent_type . "\">新建分类</a>\n";

	return $type_list_html;
}
?>
